package org.example.util6;

import java.util.Arrays;

public class EmployeeSortTest {
    public static void main(String[] args) {
        Employee[] staff = new Employee[3];
        staff[0]=new Employee("A",28000.0);
        staff[1]=new Employee("b",60050.0);
        staff[2]=new Employee("C",7000.0);
        Arrays.sort(staff);
        /*
        sort方法接收Ojbect[]数组
        Object[]数组中存储任何类型的对象，比如String、Integer、Double、自定义对象
        使用 Arrays 类的 sort 方法对 Employee 对象数组进行排序， Employee类就必须实现Compareable接口
        */
        for(Employee e:staff)
            System.out.println("name:"+e.getName()+",salary:"+e.getSalary());
    }
}
